/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.vineatoum.business.action.analyse;

import java.util.Date;
import java.util.Vector;

import org.vineatoum.business.action.abstraction.Analyse;
import org.vineatoum.view.utils.jtablecustom.TableListener;

public class AnalyseFermentation extends Analyse {
	private static String DATE = "Date de l'analyse";
	private static String DENSITY = "Densité";
	private static String TEMPERATURE = "Temperature";
	private static String COMMENT = "Commentaire";
	
	private Float density;
	private Float temperature;
	private String comment;
	
	public AnalyseFermentation() {
		date = new Date();
		density = new Float(1080);
		temperature = new Float(15);
	}

	@Override
	public TableListener getNewInstance() {
		return new AnalyseFermentation();
	}

	@Override
	public Vector<String> getVectorColumns() {
		 Vector<String> columns = new Vector<String>();
		 
		 columns.add(DATE);
		 columns.add(DENSITY);
		 columns.add(TEMPERATURE);
		 columns.add(COMMENT);
		 
		return columns;
	}

	@Override
	public Vector<Object> getVectorData() {
		Vector<Object> values = new Vector<Object>();
		
		values.add(date);
		values.add(density);
		values.add(temperature);
		values.add(comment);
		
		return values;
	}

	@Override
	public void updateField(String field, Object value) {
		try {
			if(field == DATE) {
				date = (Date)value;
			} else if (field == DENSITY) {
				density = (Float)value;
			} else if (field == TEMPERATURE) {
				temperature = (Float) value;
			} else if (field == COMMENT) {
				comment = (String) value;
			}			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	public Float getDensity() {
		return density;
	}

	public void setDensity(Float density) {
		this.density = density;
	}

	public Float getTemperature() {
		return temperature;
	}

	public void setTemperature(Float temperature) {
		this.temperature = temperature;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
}
